home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F47200_xsStrCompare1.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-07-22  |  1.5 KB  |  60 lines

  1. <xsl:stylesheet version='1.0'
  2. xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  3. xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  4. >
  5.  
  6. <xsl:output method="text"/>
  7.  
  8. <xsl:template match="/">
  9.   <xsl:text>'Paris'</xsl:text>
  10.     
  11.   <xsl:text> is</xsl:text>
  12.   <xsl:call-template name="stringCompare">
  13.     <xsl:with-param name="str1" select="'Paris'"/>
  14.     <xsl:with-param name="str2" select="'London'"/>
  15.   </xsl:call-template>
  16.   <xsl:text>'London'</xsl:text>
  17. </xsl:template>
  18.  
  19. <xsl:template name="stringCompare">
  20.   <xsl:param name="str1"/>
  21.   <xsl:param name="str2"/>
  22.     
  23.   <xsl:choose>
  24.     <xsl:when test="str1=str2">
  25.       <xsl:text> equal </xsl:text>
  26.     </xsl:when>
  27.     <xsl:otherwise>
  28.       <xsl:variable name="thePair">
  29.         <xsl:element name="str1">
  30.           <xsl:value-of select="$str1"/>
  31.         </xsl:element>
  32.         <xsl:element name="str2">
  33.           <xsl:value-of select="$str2"/>
  34.         </xsl:element>
  35.       </xsl:variable>
  36.       <xsl:variable name="sortedPair">    
  37.         <xsl:for-each select="msxsl:node-set($thePair)/*">    
  38.           <xsl:sort select="."/>    
  39.           <xsl:copy-of select="."/>
  40.         </xsl:for-each>        
  41.       </xsl:variable>
  42.             
  43.       <xsl:choose>
  44.         <xsl:when test="$str1 = msxsl:node-set($sortedPair)/*[1]">
  45.           <xsl:text> less than </xsl:text>
  46.         </xsl:when>
  47.         <xsl:otherwise>
  48.           <xsl:text> greater than </xsl:text>
  49.         </xsl:otherwise>
  50.       </xsl:choose>
  51.     </xsl:otherwise>
  52.   </xsl:choose>
  53.     
  54. </xsl:template>
  55. </xsl:stylesheet>
  56.  
  57.  
  58.  
  59.  
  60.